#include <bits/stdc++.h>

using namespace std;

class Solution
{
public:
    bool canJump(vector<int> &nums)
    {
        size_t count = 0;
        for (size_t i = 0; i <= count; i++)
        {
            count = max(count, i + nums[i]);
            if (count >= nums.size() - 1)
            {
                return true;
            }
        }
        return false;
    }
};

int main()
{
    vector<int> nums{2, 3, 1, 1, 4};
    Solution sol;
    cout << sol.canJump(nums) << endl;
    return 0;
}